<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
      全局捕获
      1. 当这个页面代码出错的时候自动执行
      2. 必须放到代码开始位置
      */
      window.onerror = function (message, url, line, col, strck) {
        console.log("错误信息", message);
        console.log("错误代码地址", url);
        console.log("错误行", line);
        console.log("错误列", col);
        console.log("错误详细信息", strck);
      };

      console.log(username);
    </script>
  </body>
</html>
